﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace WindowsPhoneToolbox.Controls
{
    /// <summary>
    /// Interaction logic for WelcomeControl.xaml
    /// </summary>
    public partial class WelcomeControl : UserControl
    {
        private readonly DispatcherTimer _timer;
        private int _count;
        private int _maxCount;
        public WelcomeControl()
        {
            InitializeComponent();
            _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) };
            _timer.Tick += TimerTick;
            _maxCount = 2;
            _timer.Start();
        }

        public void ShowTimer(int seconds)
        {
            _count = 0;
            _maxCount = seconds;
            _timer.Start();
        }

        public void Hide()
        {
            _timer.Stop();
            Visibility = Visibility.Collapsed;
        }

        public void Show()
        {
            _timer.Stop();
            Visibility = Visibility.Visible;
        }

        private void TimerTick(object sender, EventArgs e)
        {
            _count++;
            if (_count >= _maxCount)
            {
                Visibility = Visibility.Collapsed;
                _count = 0;
                _timer.Stop();
            }
        }

        private void TextBlockMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            System.Diagnostics.Process.Start("http://wphonecommands.codeplex.com");

        }

    }
}
